home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / BoxPaint / Read Me < prev    next >
Text File  |  1997-04-12  |  3KB  |  87 lines

  1. BoxPaint is a rewrite of an example in the QD 3D SDK called BoxPaint+. It 
  2. illustrates:
  3.  
  4. ・ハHow Raven's QD 3D wrapper classes make it easier to use QD 3D.
  5. ・ハUsing QD 3D pick objects.
  6. ・ハTexture mapping.
  7.  
  8. Here's an example of how the wrapper classes compare with the procedural API.
  9. First the Raven version:
  10.  
  11.     void CDocument::CreateModel()
  12.     {        
  13.         // Add the shaders
  14.         mModel.AddObject(T3DPhongShader());
  15.         mModel.AddObject(T3TextureShader(mTexture));
  16.         
  17.         // Add the styles    
  18.         mModel.AddObject(T3DInterpolationStyle(kQ3InterpolationStyleVertex));
  19.         mModel.AddObject(T3DSubdivisionStyle(kQ3SubdivisionMethodConstant, 16, 16));
  20.                 
  21.         // Our model is an ellipsoid.
  22.         T3DEllipsoid ellipsoid(kZero3DPt, T3DPoint(-1.0, 1.3, -1.0));
  23.         
  24.         mModel.AddObject(ellipsoid);
  25.  
  26.         // To get better performance we'll tell QD 3D not to save
  27.         // the state of our group when it needs to render it.
  28.         mModel.AddState(kQ3DisplayGroupStateMaskIsInline);
  29.     }
  30.  
  31. and now the SDK version:
  32.  
  33.     TQ3GroupObject MyNewModel()
  34.     {
  35.         TQ3GroupObject            myGroup = NULL;
  36.         TQ3GeometryObject        myEllipsoid;
  37.         TQ3EllipsoidData        myEllipsoidData;
  38.         TQ3ShaderObject            myIlluminationShader;
  39.         TQ3StyleObject            theStyleObject;
  40.         TQ3SubdivisionStyleData    theSubdivisionStyleData;
  41.         
  42.         if ((myGroup = Q3DisplayGroup_New()) != NULL ) {
  43.             
  44.             
  45.             /*  Define a shading type for the group */
  46.             /*  and add the shader to the group */
  47.         
  48.             myIlluminationShader = Q3PhongIllumination_New();
  49.             Q3Group_AddObject(myGroup, myIlluminationShader);
  50.             
  51.             theStyleObject = Q3InterpolationStyle_New(kQ3InterpolationStyleVertex);
  52.             Q3Group_AddObject(myGroup, theStyleObject);
  53.             Q3Object_Dispose(theStyleObject);
  54.             
  55.             theSubdivisionStyleData.method = kQ3SubdivisionMethodConstant;
  56.             theSubdivisionStyleData.c1 = 16;
  57.             theSubdivisionStyleData.c2 = 16;
  58.             
  59.             theStyleObject = Q3SubdivisionStyle_New(&theSubdivisionStyleData);
  60.             Q3Group_AddObject(myGroup, theStyleObject);
  61.             Q3Object_Dispose(theStyleObject);
  62.         
  63.             myEllipsoidData.interiorAttributeSet = NULL;
  64.             myEllipsoidData.ellipsoidAttributeSet = NULL;
  65.             myEllipsoidData.caps = kQ3EndCapNone;
  66.             
  67.             Q3Point3D_Set(&myEllipsoidData.origin, 0.0, 0.0, 0.0);
  68.             Q3Vector3D_Set(&myEllipsoidData.orientation, 0.0, 1.3, 0.0);
  69.             Q3Vector3D_Set(&myEllipsoidData.minorRadius, -1.0, 0.0, 0.0);
  70.             Q3Vector3D_Set(&myEllipsoidData.majorRadius, 0.0, 0.0, -1.0);
  71.             myEllipsoidData.uMin = 0.0; myEllipsoidData.uMax = 1.0;
  72.             myEllipsoidData.vMin = 0.0; myEllipsoidData.vMax = 1.0;
  73.  
  74.             myEllipsoid = Q3Ellipsoid_New(&myEllipsoidData);
  75.             Q3Group_AddObject(myGroup, myEllipsoid);
  76.         }
  77.     }
  78.  
  79. Note that the Raven version is 10 lines of source compared to 33 lines for the
  80. SDK version. Another major difference is that the Raven version uses exceptions
  81. to handle errors. Because CreateModel uses stack based objects there won't be any
  82. leaks if an exception is thrown. On the other hand, MyNewModel doesn't do any
  83. error checking. If error checking was added it would be substantially larger.
  84.  
  85.  
  86.  
  87.